home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DraftWn.h
-
- Contains: definition of the DraftWin and DraftInfoRec classes
-
- Owned by: Eric House
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <0> 6/7/96 eeh first checked in (moved from ::DocShell:)
-
- To Do:
- */
-
- #ifndef _DRAFTWN_
- #define _DRAFTWN_
-
- #ifndef _PLFMDEF_
- #include "PlfmDef.h"
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __LISTS__
- #include <Lists.h>
- #endif
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- #define kDraftWinNone 0
- #define kDraftWinOpen 1
- #define kDraftWinDone 2
- #define kDraftWinCreate 3
- #define kDraftWinDelete 4
- #define kDraftWinLowMemAbort 5
-
- //==============================================================================
- // Scalar Types
- //==============================================================================
-
- typedef ODULong DraftWinAction;
- struct DWStringsArray ;
-
- enum DraftInfoRecType { kDIRTypeUnknown, kDIRTypeFull, kDIRTypeDummy };
-
- //==============================================================================
- // Classes defined in this interface
- //==============================================================================
-
- class DraftWindow; // very platform dependent
- class DraftInfoRec;
- class DummyDraftInfoRec;
- class FullDraftInfoRec;
-
- //==============================================================================
- // Classes used by this interface
- //==============================================================================
-
- class DraftInfoRec
- {
- public:
- DraftInfoRec();
- ODVMethod ~DraftInfoRec();
-
- ODMethod DraftInfoRecType GetDIRType() { return fDIRType; }
-
- // I really don't need First() anymore.
- // ODMethod DraftInfoRec* First() { return fFirst; }
- ODMethod DraftInfoRec* Next() { return fNext; }
- ODMethod void SetNext(DraftInfoRec* next)
- {fNext = next; }
- ODMethod ODBoolean ShouldHilite() { return fShouldHilite; }
- ODMethod void SetShouldHilite( ODBoolean should )
- { fShouldHilite = should ; }
-
- ODMethod ODIText* GetComment() { return fComment; }
- ODMethod void SetComment( ODIText* comment) { fComment = comment; }
-
- protected:
- ODMethod void SetDIRType(DraftInfoRecType typ)
- { fDIRType = typ; }
-
- private:
- DraftInfoRecType fDIRType;
- DraftInfoRec* fNext;
- // DraftInfoRec* fFirst;
- ODBoolean fShouldHilite;
- ODIText* fComment;
- };
-
- class DummyDraftInfoRec : public DraftInfoRec
- {
- public:
- DummyDraftInfoRec();
- #if ODDebug
- ODVMethod ~DummyDraftInfoRec();
- #endif
- ODMethod void SetCommentOwner( FullDraftInfoRec* owner)
- { fCommentOwner = owner; }
- ODMethod FullDraftInfoRec* GetCommentOwner()
- { return fCommentOwner; }
-
- private:
- FullDraftInfoRec* fCommentOwner;
- };
-
- class FullDraftInfoRec : public DraftInfoRec
- {
- public:
-
- FullDraftInfoRec();
- ODNVMethod void InitDraftInfoRec(Environment* ev, ODDraft* draft);
- // note: draft reference is consumed in Init and released in destructor
- ODVMethod ~FullDraftInfoRec();
-
- ODMethod ODULong Number() { return fDraftNumber; }
- ODMethod void SetNumber(ODULong num)
- { fDraftNumber = num; }
- ODMethod ODDraft* Draft() { return fDraft; }
-
- ODMethod ODIText* GetNumberString() {return fDraftNumberString;}
- ODMethod void SetNumberString(ODIText* str)
- {fDraftNumberString = str;}
- ODMethod ODIText* GetCreated() {return fSavedString;}
- ODMethod ODIText* GetModifiedBy() {return fModifiedBy;}
-
- ODMethod ODBoolean IsExpanded() { return fCachedComment != kODNULL;}
-
- ODMethod void CacheComment()
- { fCachedComment = GetComment(); SetComment(kODNULL); }
- ODMethod void UncacheComment()
- { SetComment(fCachedComment); fCachedComment = kODNULL; }
- #if ODDebug
- ODMethod ODIText* GetCachedComment() { return fCachedComment; }
- #endif
-
- ODMethod ODBoolean CanExpand() { return fCanExpand; }
- // The only thing to set this to is true.
- ODMethod void SetCanExpand() { fCanExpand = kODTrue; }
-
- private:
- ODDraft* fDraft;
- ODStorageUnit* fDraftProperties;
- ODDraftID fDraftID;
- ODULong fDraftNumber;
- ODIText* fDraftNumberString;
- ODULong fSaved;
- ODIText* fSavedString;
- ODIText* fCachedComment; // null unless expanded
- ODIText* fModifiedBy;
- ODBoolean fCanExpand; // the comment is too long and may be expanded
- };
-
-
- //==============================================================================
- // DraftWindow
- //==============================================================================
-
- class DraftWindow
- {
- public:
-
- DraftWindow();
- ODNVMethod void InitDraftWindow(Environment* ev, ODDraft* draft);
- ODVMethod ~DraftWindow();
-
- ODMethod DraftWinAction Drafts(Environment* ev, ODDraft* draft,
- DraftWinAction prevAction, ODBoolean hasWriteAccess);
- ODMethod FullDraftInfoRec* InternalizeHistory(Environment* ev);
- ODMethod ODDraft* GetSelectedDraft() {return fSelectedDraft;}
-
- //ODMethod void DraftCreated(Environment* ev, ODDraft* draft);
- ODMethod void DraftSaved(Environment* ev, ODDraft* draft);
- // used to set the Draft Properties
- // can be used independently of other methods including initialize
-
-
- ODMethod ODSShort CountDrafts() ;
- ODMethod ListHandle GetListHandle() {return fListH;}
- ODMethod ODBoolean CreateIsSet() {return fCreateSet;}
- ODMethod void SetReadyToClose(ODBoolean readyToClose)
- { fReadyToClose = readyToClose; }
- ODMethod ODBoolean ReadyToClose()
- { return fReadyToClose; }
- ODMethod void GetListRect(Rect* r) {*r = fListRect;}
- ODMethod void DeleteSelectedDraft(Environment* ev, ODSession* session);
-
- ODMethod void SetHilite( DraftInfoRec* from, short whichRow );
- ODMethod ODBoolean ProcessMousedownInList( DialogPtr dialog,
- ListHandle listH, Point mpt );
-
- protected:
- ODMethod ODBoolean CreateDraft(Environment* ev);
- ODMethod ODBoolean RemoveSelectedDrafts(Environment* ev);
- ODMethod void Print();
-
- ODMethod ListHandle MakeAList( DialogPtr dlg, ODSShort* numLines,
- long refcon );
-
- #if ODDebug
- ODMethod void CheckConsistency();
- #endif
- private:
- ODDraft* fDraft;
- ODDocument* fDocument;
- FullDraftInfoRec* fDraftInfo;
- ODDraft* fSelectedDraft;
- ODULong fSelectedDraftNumber;
- ListHandle fListH;
- Rect fListRect;
- ODBoolean fCreateSet;
- FullDraftInfoRec* fHilitedRow;
- ODBoolean fReadyToClose;
- };
-
- #endif // _DRAFTWIN_
-